﻿/// <reference path="RemoteKmDb.js"/>
/// <reference path="BrowserKmDb.js"/>
/// <reference path="LoadLocal.js"/>
/// <reference path="jquery-1.5-vsdoc.js"/>
/// <reference path="jquery.json.js"/>
/// <reference path="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.js"/>
/// <reference path="Helper.js"/>
/// <reference path="Params.js"/>

var _online = navigator.onLine;

function areWeOnline() {
    var o = $("div[data-role=header]");
    if (!_online) {
        o.attr("data-theme", "e").removeClass("ui-btn-up-b").addClass("ui-btn-up-e");
    }
    else {
        o.attr("data-theme", "a").removeClass("ui-btn-up-e").addClass("ui-btn-up-a");
    }
}

function ApplicationStateChanged() {
    areWeOnline();
    loadOrCreateKilometers(null);
    if (_online) {
        syncToRemoteKilometers(); // SYNC TO REMOTE
        syncFromRemoteKilometers();
    }   
}